<?php

namespace app\site\controller;

use app\common\model\SiteModel;
use think\Request;

class SiteController extends BaseController
{

    private $siteModel;
    private $tradeList;

    /**
     * 初始化
     */
    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->siteModel = new SiteModel();
        $this->tradeList = cache('trade');
    }

    /**
     * 修改数据
     * @return mixed
     */
    public function info()
    {
        if ($this->request->isAjax()) {
            $data   = $this->request->param();
            $data['site_id'] = $this->getSiteId();
            $result = $this->validate($data, 'SiteValidate.info');
            if (true !== $result) {
                $this->error($result);
            }
            if ($this->siteModel->editData($data)) {
                $this->success('修改成功！');
            } else {
                echo $this->siteModel->getLastSql();
                $this->error($this->siteModel->getError());
            }
        }
        $info   = $this->siteModel->get($this->getSiteId());
        $this->assign('info', $info);
        $this->assign('tradeList', $this->tradeList);
        return $this->fetch();
    }
    /**
     * 企业风格
     * @return mixed
     */
    public function theme(){
        return $this->fetch();
    }

}
